import os
import tornado.web
from main import *

settings = {
    'static_path': os.path.join(os.path.dirname(__file__), 'static'),
    'cookie_secret': '__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__',
    'login_url': '/login',
    'debug': True,
    # 'xsrf_cookies': True,
    'pycket': {
        "engine": "redis",  # 配置存储类型
        "storage": {
            "host": "192.168.0.115",
            "port": 6379,
            "db_sessions": 1,
            "db_notifications": 11,
            "max_connections": 2 ** 31
        },
        "cookies": {
            # 设置过期时间
            "expires_days": 7,
        }
    },

}

application = tornado.web.Application([
    (r'/', MainHandler),
    (r'/detail', DetailHandler),
    (r'/register', RegisterHandler),
    (r'/send_msg', SendCodeHandler),
    (r'/login', LoginHandler),
    (r'/chat', ChatHandler),
    (r'/chat-server', WebRTCServer),
    (r'/logout', LogoutHandler),
    (r'/admin_index', AdminIndexHandler),
    (r'/shop_manage', ShopManageHandler),
    (r'/admin_add_shop', AdminAddGoods),
    (r'/admin_add_shop_images', GoodImageHandler),
    (r'/(apple-touch-icon\.png)', tornado.web.StaticFileHandler, dict(path=settings['static_path'])),
], **settings)
